package com.atguigu.springcloud.controller;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 流控规则和降级处理
 * @author 孙志鹏
 * @createDate 2022/5/5 14:36
 */
@RestController
public class FlowLimitController {

    @GetMapping("/testA")
    public String testA()
    {
        return "------testA";
    }

    @GetMapping("/testB")
    public String testB()
    {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "------testB";
    }

    /**
     * 测试Sentinel降级Rt
     * @return
     */
    @GetMapping("/testC")
    public String testC() {
        try {
            Thread.sleep(2000);
        } catch (InterruptedException e) {
            e.printStackTrace();
        }
        return "--------testC";
    }

    /**
     * 测试Sentinel降级异常比例
     * @return
     */
    @GetMapping("/testD")
    public String testD() {
        int i = 1/0;
        return "-------testD";
    }

    /**
     * 测试Sentinel降级异常数量
     * @return
     */
    @GetMapping("/testE")
    public String testE() {
        int i = 1/0;
        return "------testE";
    }

}
